package com.baizhi.service.impl;

import com.baizhi.dao.UserDao;
import com.baizhi.entity.User;
import com.baizhi.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Lenovo on 2019/6/19.
 */
@Service
public class UserServiceImpl implements UserService{

    @Autowired
    private UserDao userDao;
    //分页查询
    @Override
    public Map fenye(int page, int rows, String userName) {
        if(userName!=null&&!"".equals(userName)){
            userName="%"+userName+"%";
        }else {
            userName=null;
        }
        Map map=new HashMap();
        int total = userDao.Total(userName);
        map.put("total",total);
        int start=(page-1)*rows;
        int pageSize=page*rows;
        List<User> list = userDao.fenye(start, pageSize, userName);
        map.put("rows",list);
        return map;
    }


    //查男女
    @Override
    public List<Map> selectSexCount() {
        List<Map> maps = userDao.selectSexCount();
        return maps;
    }


}
